package com.dragon.refect.error;

import java.util.ArrayList;

/**
 * -Xms100m -Xmx100m -XX:+UseSerialGC
 * @author dragon
 * @since 2019/12/12
 */
public class JConsoleTest {

    static class OOMObject {

        public byte[] palceholder = new byte[64 * 1024];
    }

    public static void main(String[] args) throws InterruptedException {
        fillHeap(10000);
    }

    public static void fillHeap(int num) throws InterruptedException {
        ArrayList<OOMObject> list = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            Thread.sleep(50);
            list.add(new OOMObject());
        }
        System.gc();

    }
}
